from django.db import models

# Create your models here.

#定义数据模型，一个数据模型对应一个数据表
class User(models.Model):
    genderchoices=[('男','M'),('女','F')]
    name=models.CharField(max_length=16,unique=True,null=False)
    password=models.CharField(max_length=16)
    gender=models.CharField(max_length=16,choices=genderchoices)
    age=models.IntegerField()

class Project(models.Model):
    user_id=models.IntegerField()
    project_name=models.CharField(max_length=64,unique=True)
    start_time=models.DateField()
    end_time=models.DateField()
    status=models.CharField(max_length=64)
    create_time=models.DateField(auto_now_add=True)

class Author(models.Model):
    name=models.CharField(max_length=16,unique=True)
    gender=models.CharField(max_length=8)
    age=models.IntegerField()
    address=models.CharField(max_length=32)

class Book(models.Model):
    categorychoices=[('历史','历史'),('心理学','心理学'),('武侠','武侠'),('文学','文学')]
    name = models.CharField(max_length=16, unique=True)
    price=models.DecimalField(max_digits=8,decimal_places=2)
    category=models.CharField(max_length=8,choices=categorychoices)
    pubishdate=models.DateTimeField(null=False)
    pubisher=models.CharField(max_length=16,default='清华出版社')
    author=models.ForeignKey(Author,on_delete=models.CASCADE,related_name='book')
    createtime=models.DateTimeField(auto_now_add=True)
    updatetime=models.DateTimeField(auto_now=True)

class Address(models.Model):
    addressdetail=models.CharField(max_length=64,unique=True)
    city=models.CharField(max_length=64)
    province=models.CharField(max_length=64)
    zip=models.IntegerField(default=100100)

class Mstore(models.Model):
    name=models.CharField(max_length=64,unique=True)
    manager=models.CharField(max_length=64)
    startdate=models.DateField()
    address=models.OneToOneField(Address,on_delete=models.CASCADE,related_name='mstore')

class TestCase(models.Model):
    name=models.CharField(max_length=64,primary_key=True)
    step=models.TextField()
    expect=models.CharField(max_length=128)
    acutal=models.CharField(max_length=128)

